package com.news.news.web;

import com.news.news.modle.Comment;
import com.news.news.service.CommentService;
import com.news.news.util.CommonResult;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping(path = "/userApi/CommentCtl")
public class UserCommentController {

    @Resource
    CommentService commentService;
    /**
     * 获取用户评论信息
     * @param
     * @return
     */
    @RequestMapping(value = "/CommentList")
    public CommonResult CommentList(@RequestHeader("userToken") String token) {
        List<Comment> list = commentService.GetCommentList(token);
        CommonResult commonResult=new CommonResult(200,list,"成功");
        return commonResult;
    }

    /**
     * 删除用户评论
     * @param token
     * @return
     */
    @RequestMapping(value = "/deleteComment")
    public CommonResult deleteComment(@RequestHeader("userToken") String token,int newsid,int commentId) {
         commentService.deleteComment(token,newsid,commentId);
        CommonResult commonResult=new CommonResult(200,null,"成功");
        return commonResult;
    }
}
